<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/** @license
<span class='line'>  2</span>  * Copyright (c) 2010 James Hall, https://github.com/MrRio/jsPDF
<span class='line'>  3</span>  * Copyright (c) 2012 Willow Systems Corporation, willow-systems.com
<span class='line'>  4</span>  * 
<span class='line'>  5</span>  * Permission is hereby granted, free of charge, to any person obtaining
<span class='line'>  6</span>  * a copy of this software and associated documentation files (the
<span class='line'>  7</span>  * "Software"), to deal in the Software without restriction, including
<span class='line'>  8</span>  * without limitation the rights to use, copy, modify, merge, publish,
<span class='line'>  9</span>  * distribute, sublicense, and/or sell copies of the Software, and to
<span class='line'> 10</span>  * permit persons to whom the Software is furnished to do so, subject to
<span class='line'> 11</span>  * the following conditions:
<span class='line'> 12</span>  * 
<span class='line'> 13</span>  * The above copyright notice and this permission notice shall be
<span class='line'> 14</span>  * included in all copies or substantial portions of the Software.
<span class='line'> 15</span>  * 
<span class='line'> 16</span>  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
<span class='line'> 17</span>  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
<span class='line'> 18</span>  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
<span class='line'> 19</span>  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
<span class='line'> 20</span>  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
<span class='line'> 21</span>  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
<span class='line'> 22</span>  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
<span class='line'> 23</span>  */</span><span class="WHIT">
<span class='line'> 24</span> 
<span class='line'> 25</span> </span><span class="COMM">/**
<span class='line'> 26</span>  * Creates new jsPDF document object instance
<span class='line'> 27</span>  * @constructor jsPDF
<span class='line'> 28</span>  * @param orientation One of "portrait" or "landscape" (or shortcuts "p" (Default), "l")
<span class='line'> 29</span>  * @param unit Measurement unit to be used when coordinates are specified. One of "pt" (points), "mm" (Default), "cm", "in"
<span class='line'> 30</span>  * @param format One of 'a3', 'a4' (Default),'a5' ,'letter' ,'legal'
<span class='line'> 31</span>  * @returns {jsPDF}
<span class='line'> 32</span>  */</span><span class="WHIT">
<span class='line'> 33</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">jsPDF</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="COMM">/** String */</span><span class="WHIT"> </span><span class="NAME">orientation</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">/** String */</span><span class="WHIT"> </span><span class="NAME">unit</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">/** String */</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 34</span> 
<span class='line'> 35</span> </span><span class="WHIT">	</span><span class="COMM">// Default parameter values</span><span class="WHIT">
<span class='line'> 36</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">orientation</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">orientation</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'p'</span><span class="WHIT">
<span class='line'> 37</span> </span><span class="WHIT">	</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="NAME">orientation</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">orientation.toString</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toLowerCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> 
<span class='line'> 38</span> 	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">unit</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">unit</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'mm'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 39</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">format</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">format</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'a4'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 40</span> </span><span class="WHIT">	
<span class='line'> 41</span> 	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">format_as_string</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">format.toString</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toLowerCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> 
<span class='line'> 42</span> 	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">HELVETICA</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"helvetica"</span><span class="WHIT">
<span class='line'> 43</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">TIMES</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"times"</span><span class="WHIT">
<span class='line'> 44</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">COURIER</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"courier"</span><span class="WHIT">
<span class='line'> 45</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">NORMAL</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"normal"</span><span class="WHIT">
<span class='line'> 46</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">BOLD</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"bold"</span><span class="WHIT">
<span class='line'> 47</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ITALIC</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"italic"</span><span class="WHIT">
<span class='line'> 48</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">BOLD_ITALIC</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"bolditalic"</span><span class="WHIT">
<span class='line'> 49</span> 
<span class='line'> 50</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">version</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'20120220'</span><span class="WHIT">
<span class='line'> 51</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">content</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'> 52</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">content_length</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT">
<span class='line'> 53</span> </span><span class="WHIT">	
<span class='line'> 54</span> 	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pdfVersion</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'1.3'</span><span class="WHIT"> </span><span class="COMM">// PDF Version</span><span class="WHIT">
<span class='line'> 55</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pageFormats</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// Size in pt of various paper formats</span><span class="WHIT">
<span class='line'> 56</span> </span><span class="WHIT">		</span><span class="STRN">'a3'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NUMB">841.89</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1190.55</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'> 57</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'a4'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NUMB">595.28</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">841.89</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'> 58</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'a5'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NUMB">420.94</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">595.28</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'> 59</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'letter'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NUMB">612</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">792</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'> 60</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'legal'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NUMB">612</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1008</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'> 61</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 62</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">textColor</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'0 g'</span><span class="WHIT">
<span class='line'> 63</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">drawColor</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'0 G'</span><span class="WHIT">
<span class='line'> 64</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">page</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT">
<span class='line'> 65</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">objectNumber</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="WHIT"> </span><span class="COMM">// 'n' Current object number</span><span class="WHIT">
<span class='line'> 66</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">outToPages</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="WHIT"> </span><span class="COMM">// switches where out() prints. outToPages true = push to pages obj. outToPages false = doc builder content </span><span class="WHIT">
<span class='line'> 67</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pages</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'> 68</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">offsets</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="COMM">// List of offsets. Activated and reset by buildDocument(). Pupulated by various calls buildDocument makes.</span><span class="WHIT">
<span class='line'> 69</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fonts</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="COMM">// List of fonts</span><span class="WHIT">
<span class='line'> 70</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">lineWidth</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0.200025</span><span class="WHIT"> </span><span class="COMM">// 2mm</span><span class="WHIT">
<span class='line'> 71</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pageHeight</span><span class="WHIT">
<span class='line'> 72</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pageWidth</span><span class="WHIT">
<span class='line'> 73</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">k</span><span class="WHIT"> </span><span class="COMM">// Scale factor</span><span class="WHIT">
<span class='line'> 74</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fontNumber</span><span class="WHIT"> </span><span class="COMM">// @TODO: This is temp, replace with real font handling</span><span class="WHIT">
<span class='line'> 75</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">documentProperties</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 76</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fontSize</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="WHIT"> </span><span class="COMM">// Default font size</span><span class="WHIT">
<span class='line'> 77</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fontName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">HELVETICA</span><span class="WHIT"> </span><span class="COMM">// Default font</span><span class="WHIT">
<span class='line'> 78</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fontType</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">NORMAL</span><span class="WHIT"> </span><span class="COMM">// Default type</span><span class="WHIT">
<span class='line'> 79</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">textColor</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"0 g"</span><span class="WHIT">
<span class='line'> 80</span> 
<span class='line'> 81</span> </span><span class="WHIT">	</span><span class="COMM">// Private functions</span><span class="WHIT">
<span class='line'> 82</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">out</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">string</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 83</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">outToPages</span><span class="WHIT"> </span><span class="COMM">/* set by beginPage */</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 84</span> </span><span class="WHIT">			</span><span class="NAME">pages</span><span class="PUNC">[</span><span class="NAME">page</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">push</span><span class="PUNC">(</span><span class="NAME">string</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 85</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 86</span> </span><span class="WHIT">			</span><span class="NAME">content.push</span><span class="PUNC">(</span><span class="NAME">string</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 87</span> </span><span class="WHIT">			</span><span class="NAME">content_length</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">string.length</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="COMM">// +1 is for '\n' that will be used to join contents of content </span><span class="WHIT">
<span class='line'> 88</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 89</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 90</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">newObject</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 91</span> </span><span class="WHIT">		</span><span class="COMM">// Begin a new object</span><span class="WHIT">
<span class='line'> 92</span> </span><span class="WHIT">		</span><span class="NAME">objectNumber</span><span class="WHIT"> </span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 93</span> </span><span class="WHIT">		</span><span class="NAME">offsets</span><span class="PUNC">[</span><span class="NAME">objectNumber</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">content_length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 94</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">objectNumber</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' 0 obj'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">		
<span class='line'> 95</span> 	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 96</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">putPages</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 97</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">wPt</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pageWidth</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 98</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hPt</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pageHeight</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 99</span> 
<span class='line'>100</span> </span><span class="WHIT">		</span><span class="COMM">// outToPages = false as set in endDocument(). out() writes to content.</span><span class="WHIT">
<span class='line'>101</span> </span><span class="WHIT">		
<span class='line'>102</span> 		</span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">=</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">&lt;=</span><span class="WHIT"> </span><span class="NAME">page</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">n</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>103</span> </span><span class="WHIT">			</span><span class="NAME">newObject</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>104</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'&lt;&lt;/Type /Page'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>105</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Parent 1 0 R'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">	
<span class='line'>106</span> 			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Resources 2 0 R'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>107</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Contents '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">objectNumber</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' 0 R>>'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>108</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'endobj'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>109</span> </span><span class="WHIT">			
<span class='line'>110</span> 			</span><span class="COMM">// Page content</span><span class="WHIT">
<span class='line'>111</span> </span><span class="WHIT">			</span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pages</span><span class="PUNC">[</span><span class="NAME">n</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">join</span><span class="PUNC">(</span><span class="STRN">'\n'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>112</span> </span><span class="WHIT">			</span><span class="NAME">newObject</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>113</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'&lt;&lt;/Length '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">p.length</span><span class="WHIT">  </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'>>'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>114</span> </span><span class="WHIT">			</span><span class="NAME">putStream</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>115</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'endobj'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>116</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>117</span> </span><span class="WHIT">		</span><span class="NAME">offsets</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">content_length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>118</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'1 0 obj'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>119</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'&lt;&lt;/Type /Pages'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>120</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">kids</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'/Kids ['</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>121</span> </span><span class="WHIT">		</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">page</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>122</span> </span><span class="WHIT">			</span><span class="NAME">kids</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NUMB">3</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' 0 R '</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>123</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>124</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">kids</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">']'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>125</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Count '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">page</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>126</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">sprintf</span><span class="PUNC">(</span><span class="STRN">'/MediaBox [0 0 %.2f %.2f]'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">wPt</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">hPt</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>127</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'>>'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>128</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'endobj'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">		
<span class='line'>129</span> 	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>130</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">putStream</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>131</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'stream'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>132</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>133</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'endstream'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>134</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>135</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">putResources</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>136</span> </span><span class="WHIT">		</span><span class="NAME">putFonts</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>137</span> </span><span class="WHIT">		</span><span class="COMM">// Resource dictionary</span><span class="WHIT">
<span class='line'>138</span> </span><span class="WHIT">		</span><span class="NAME">offsets</span><span class="PUNC">[</span><span class="NUMB">2</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">content_length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>139</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'2 0 obj'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>140</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'&lt;&lt;'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>141</span> </span><span class="WHIT">		</span><span class="NAME">putResourceDictionary</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>142</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'>>'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>143</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'endobj'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>144</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">	
<span class='line'>145</span> 	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">putFonts</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>146</span> </span><span class="WHIT">		</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">fonts.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>147</span> </span><span class="WHIT">			</span><span class="NAME">putFont</span><span class="PUNC">(</span><span class="NAME">fonts</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>148</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>149</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>150</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">putFont</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">font</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>151</span> </span><span class="WHIT">		</span><span class="NAME">newObject</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>152</span> </span><span class="WHIT">		</span><span class="NAME">font.number</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">objectNumber</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>153</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'&lt;&lt;/BaseFont/'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">font.name</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'/Type/Font'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>154</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Subtype/Type1>>'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>155</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'endobj'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>156</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>157</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">addFont</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fontName</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fontType</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>158</span> </span><span class="WHIT">		</span><span class="NAME">fonts.push</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="NAME">key</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'F'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">fonts.length</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">number</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">objectNumber</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">name</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fontName</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">fontName</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">fontType</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>159</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>160</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">addFonts</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>161</span> </span><span class="WHIT">		</span><span class="NAME">addFont</span><span class="PUNC">(</span><span class="STRN">'Helvetica'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">HELVETICA</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">NORMAL</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>162</span> </span><span class="WHIT">		</span><span class="NAME">addFont</span><span class="PUNC">(</span><span class="STRN">'Helvetica-Bold'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">HELVETICA</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">BOLD</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>163</span> </span><span class="WHIT">		</span><span class="NAME">addFont</span><span class="PUNC">(</span><span class="STRN">'Helvetica-Oblique'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">HELVETICA</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ITALIC</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>164</span> </span><span class="WHIT">		</span><span class="NAME">addFont</span><span class="PUNC">(</span><span class="STRN">'Helvetica-BoldOblique'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">HELVETICA</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">BOLD_ITALIC</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>165</span> </span><span class="WHIT">		</span><span class="NAME">addFont</span><span class="PUNC">(</span><span class="STRN">'Courier'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">COURIER</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">NORMAL</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>166</span> </span><span class="WHIT">		</span><span class="NAME">addFont</span><span class="PUNC">(</span><span class="STRN">'Courier-Bold'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">COURIER</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">BOLD</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>167</span> </span><span class="WHIT">		</span><span class="NAME">addFont</span><span class="PUNC">(</span><span class="STRN">'Courier-Oblique'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">COURIER</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ITALIC</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>168</span> </span><span class="WHIT">		</span><span class="NAME">addFont</span><span class="PUNC">(</span><span class="STRN">'Courier-BoldOblique'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">COURIER</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">BOLD_ITALIC</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>169</span> </span><span class="WHIT">		</span><span class="NAME">addFont</span><span class="PUNC">(</span><span class="STRN">'Times-Roman'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">TIMES</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">NORMAL</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>170</span> </span><span class="WHIT">		</span><span class="NAME">addFont</span><span class="PUNC">(</span><span class="STRN">'Times-Bold'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">TIMES</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">BOLD</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>171</span> </span><span class="WHIT">		</span><span class="NAME">addFont</span><span class="PUNC">(</span><span class="STRN">'Times-Italic'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">TIMES</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ITALIC</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>172</span> </span><span class="WHIT">		</span><span class="NAME">addFont</span><span class="PUNC">(</span><span class="STRN">'Times-BoldItalic'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">TIMES</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">BOLD_ITALIC</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>173</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>174</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">putResourceDictionary</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>175</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>176</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Font &lt;&lt;'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>177</span> </span><span class="WHIT">		</span><span class="COMM">// Do this for each font, the '1' bit is the index of the font</span><span class="WHIT">
<span class='line'>178</span> </span><span class="WHIT">		</span><span class="COMM">// fontNumber is currently the object number related to 'putFonts'</span><span class="WHIT">
<span class='line'>179</span> </span><span class="WHIT">		</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">fonts.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>180</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">fonts</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">fonts</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">number</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' 0 R'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>181</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>182</span> </span><span class="WHIT">		
<span class='line'>183</span> 		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'>>'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>184</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/XObject &lt;&lt;'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>185</span> </span><span class="WHIT">		</span><span class="NAME">putXobjectDict</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>186</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'>>'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>187</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>188</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">putXobjectDict</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>189</span> </span><span class="WHIT">		</span><span class="COMM">// @TODO: Loop through images, or other data objects</span><span class="WHIT">
<span class='line'>190</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>191</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">putInfo</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>192</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Producer (jsPDF '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">version</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">')'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>193</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">documentProperties.title</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>194</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Title ('</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pdfEscape</span><span class="PUNC">(</span><span class="NAME">documentProperties.title</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">')'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>195</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>196</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">documentProperties.subject</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>197</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Subject ('</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pdfEscape</span><span class="PUNC">(</span><span class="NAME">documentProperties.subject</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">')'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>198</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>199</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">documentProperties.author</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>200</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Author ('</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pdfEscape</span><span class="PUNC">(</span><span class="NAME">documentProperties.author</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">')'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>201</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>202</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">documentProperties.keywords</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>203</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Keywords ('</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pdfEscape</span><span class="PUNC">(</span><span class="NAME">documentProperties.keywords</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">')'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>204</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>205</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">documentProperties.creator</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>206</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Creator ('</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pdfEscape</span><span class="PUNC">(</span><span class="NAME">documentProperties.creator</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">')'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>207</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">		
<span class='line'>208</span> 		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">created</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Date</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>209</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/CreationDate (D:'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">sprintf</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>210</span> </span><span class="WHIT">			</span><span class="STRN">'%02d%02d%02d%02d%02d%02d'</span><span class="WHIT">
<span class='line'>211</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">created.getFullYear</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>212</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">created.getMonth</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>213</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">created.getDate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>214</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">created.getHours</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>215</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">created.getMinutes</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>216</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">created.getSeconds</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>217</span> </span><span class="WHIT">		</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">')'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>218</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>219</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">putCatalog</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>220</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Type /Catalog'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>221</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Pages 1 0 R'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>222</span> </span><span class="WHIT">		</span><span class="COMM">// @TODO: Add zoom and layout modes</span><span class="WHIT">
<span class='line'>223</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/OpenAction [3 0 R /FitH null]'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>224</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/PageLayout /OneColumn'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>225</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">	
<span class='line'>226</span> 	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">putTrailer</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>227</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Size '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">objectNumber</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>228</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Root '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">objectNumber</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' 0 R'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>229</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Info '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">objectNumber</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' 0 R'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>230</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">	
<span class='line'>231</span> 	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">beginPage</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>232</span> </span><span class="WHIT">		</span><span class="NAME">page</span><span class="WHIT"> </span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>233</span> </span><span class="WHIT">		</span><span class="COMM">// Do dimension stuff</span><span class="WHIT">
<span class='line'>234</span> </span><span class="WHIT">		</span><span class="NAME">outToPages</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="WHIT">
<span class='line'>235</span> </span><span class="WHIT">		</span><span class="NAME">pages</span><span class="PUNC">[</span><span class="NAME">page</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>236</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>237</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">_addPage</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>238</span> </span><span class="WHIT">		</span><span class="NAME">beginPage</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>239</span> </span><span class="WHIT">		</span><span class="COMM">// Set line width</span><span class="WHIT">
<span class='line'>240</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">sprintf</span><span class="PUNC">(</span><span class="STRN">'%.2f w'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">lineWidth</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>241</span> </span><span class="WHIT">		</span><span class="COMM">// Set draw color</span><span class="WHIT">
<span class='line'>242</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">drawColor</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>243</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>244</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">getFont</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>245</span> </span><span class="WHIT">		</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">fonts.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>246</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">fonts</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">fontName</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">fontName</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">fonts</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">fontType</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>247</span> </span><span class="WHIT">				</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">fonts</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">key</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>248</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>249</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>250</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">'F1'</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// shouldn't happen</span><span class="WHIT">
<span class='line'>251</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>252</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">buildDocument</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>253</span> </span><span class="WHIT">		
<span class='line'>254</span> 		</span><span class="NAME">outToPages</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="WHIT"> </span><span class="COMM">// switches out() to content</span><span class="WHIT">
<span class='line'>255</span> </span><span class="WHIT">		</span><span class="NAME">content</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>256</span> </span><span class="WHIT">		</span><span class="NAME">offsets</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>257</span> </span><span class="WHIT">		
<span class='line'>258</span> 		</span><span class="COMM">// putHeader();</span><span class="WHIT">
<span class='line'>259</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'%PDF-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pdfVersion</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>260</span> </span><span class="WHIT">		
<span class='line'>261</span> 		</span><span class="NAME">putPages</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>262</span> </span><span class="WHIT">		
<span class='line'>263</span> 		</span><span class="NAME">putResources</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>264</span> 
<span class='line'>265</span> </span><span class="WHIT">		</span><span class="COMM">// Info</span><span class="WHIT">
<span class='line'>266</span> </span><span class="WHIT">		</span><span class="NAME">newObject</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>267</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'&lt;&lt;'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>268</span> </span><span class="WHIT">		</span><span class="NAME">putInfo</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>269</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'>>'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>270</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'endobj'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>271</span> </span><span class="WHIT">		
<span class='line'>272</span> 		</span><span class="COMM">// Catalog</span><span class="WHIT">
<span class='line'>273</span> </span><span class="WHIT">		</span><span class="NAME">newObject</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>274</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'&lt;&lt;'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>275</span> </span><span class="WHIT">		</span><span class="NAME">putCatalog</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>276</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'>>'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>277</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'endobj'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>278</span> </span><span class="WHIT">		
<span class='line'>279</span> 		</span><span class="COMM">// Cross-ref</span><span class="WHIT">
<span class='line'>280</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">o</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">content_length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>281</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'xref'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>282</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'0 '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">objectNumber</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>283</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'0000000000 65535 f '</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>284</span> </span><span class="WHIT">		</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">=</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;=</span><span class="WHIT"> </span><span class="NAME">objectNumber</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>285</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">sprintf</span><span class="PUNC">(</span><span class="STRN">'%010d 00000 n '</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">offsets</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>286</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>287</span> </span><span class="WHIT">		</span><span class="COMM">// Trailer</span><span class="WHIT">
<span class='line'>288</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'trailer'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>289</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'&lt;&lt;'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>290</span> </span><span class="WHIT">		</span><span class="NAME">putTrailer</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>291</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'>>'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>292</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'startxref'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>293</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">o</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>294</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'%%EOF'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>295</span> </span><span class="WHIT">		
<span class='line'>296</span> 		</span><span class="NAME">outToPages</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="WHIT">
<span class='line'>297</span> </span><span class="WHIT">		
<span class='line'>298</span> 		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">content.join</span><span class="PUNC">(</span><span class="STRN">'\n'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>299</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>300</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pdfEscape</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">text</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>301</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">text.replace</span><span class="PUNC">(</span><span class="REGX">/\\/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'\\\\'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="REGX">/\(/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'\\('</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="REGX">/\)/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'\\)'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>302</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>303</span> </span><span class="WHIT">	
<span class='line'>304</span> 	</span><span class="COMM">// Public API</span><span class="WHIT">
<span class='line'>305</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">_jsPDF</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>306</span> </span><span class="WHIT">		</span><span class="COMM">/**
<span class='line'>307</span> 		 * Adds (and transfers the focus to) new page to the PDF document.
<span class='line'>308</span> 		 * @function
<span class='line'>309</span> 		 * @returns {jsPDF} 
<span class='line'>310</span> 		 * @name jsPDF.addPage
<span class='line'>311</span> 		 */</span><span class="WHIT">
<span class='line'>312</span> </span><span class="WHIT">		</span><span class="NAME">addPage</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>313</span> </span><span class="WHIT">			</span><span class="NAME">_addPage</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>314</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_jsPDF</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>315</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>316</span> </span><span class="WHIT">		</span><span class="COMM">/**
<span class='line'>317</span> 		 * Adds text to page. Supports adding multiline text when 'text' argument is an Array of Strings. 
<span class='line'>318</span> 		 * @param {Number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
<span class='line'>319</span> 		 * @param {Number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
<span class='line'>320</span> 		 * @param {String|Array} text String or array of strings to be added to the page. Each line is shifted one line down per font, spacing settings declared before this call.
<span class='line'>321</span> 		 * @function
<span class='line'>322</span> 		 * @returns {jsPDF}
<span class='line'>323</span> 		 * @name jsPDF.text
<span class='line'>324</span> 		 */</span><span class="WHIT">
<span class='line'>325</span> </span><span class="WHIT">		</span><span class="NAME">text</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">text</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>326</span> </span><span class="WHIT">			</span><span class="COMM">/**
<span class='line'>327</span> 			 * Inserts something like this into PDF
<span class='line'>328</span> 				BT 
<span class='line'>329</span> 				/F1 16 Tf  % Font name + size
<span class='line'>330</span> 				16 TL % How many units down for next line in multiline text
<span class='line'>331</span> 				0 g % color
<span class='line'>332</span> 				28.35 813.54 Td % position
<span class='line'>333</span> 				(line one) Tj 
<span class='line'>334</span> 				T* (line two) Tj
<span class='line'>335</span> 				T* (line three) Tj
<span class='line'>336</span> 				ET
<span class='line'>337</span> 		 	*/</span><span class="WHIT">
<span class='line'>338</span> </span><span class="WHIT">			
<span class='line'>339</span> 			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">newtext</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">str</span><span class="WHIT">
<span class='line'>340</span> 
<span class='line'>341</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">text</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>342</span> </span><span class="WHIT">				</span><span class="NAME">str</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pdfEscape</span><span class="PUNC">(</span><span class="NAME">text</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>343</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="COMM">/* Array */</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>344</span> </span><span class="WHIT">				</span><span class="COMM">// we don't want to destroy  original text array, so cloning it</span><span class="WHIT">
<span class='line'>345</span> </span><span class="WHIT">				</span><span class="NAME">newtext</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">text.concat</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>346</span> </span><span class="WHIT">				</span><span class="COMM">// we do array.join('text that must not be PDFescaped")</span><span class="WHIT">
<span class='line'>347</span> </span><span class="WHIT">				</span><span class="COMM">// thus, pdfEscape eash component separately</span><span class="WHIT">
<span class='line'>348</span> </span><span class="WHIT">				</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">newtext.length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">--</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>349</span> </span><span class="WHIT">					</span><span class="NAME">newtext</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pdfEscape</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">newtext</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>350</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>351</span> </span><span class="WHIT">				</span><span class="NAME">str</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">newtext.join</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="STRN">") Tj\nT* ("</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>352</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>353</span> </span><span class="WHIT">			</span><span class="COMM">// Using "'" ("go next line and render text" mark) would save space but would complicate our rendering code, templates </span><span class="WHIT">
<span class='line'>354</span> </span><span class="WHIT">			
<span class='line'>355</span> 			</span><span class="COMM">// BT .. ET does NOT have default settings for Tf. You must state that explicitely every time for BT .. ET</span><span class="WHIT">
<span class='line'>356</span> </span><span class="WHIT">			</span><span class="COMM">// if you want text transformation matrix (+ multiline) to work reliably (which reads sizes of things from font declarations) </span><span class="WHIT">
<span class='line'>357</span> </span><span class="WHIT">			</span><span class="COMM">// Thus, there is NO useful, *reliable* concept of "default" font for a page. </span><span class="WHIT">
<span class='line'>358</span> </span><span class="WHIT">			</span><span class="COMM">// The fact that "default" (reuse font used before) font worked before in basic cases is an accident</span><span class="WHIT">
<span class='line'>359</span> </span><span class="WHIT">			</span><span class="COMM">// - readers dealing smartly with brokenness of jsPDF's markup.</span><span class="WHIT">
<span class='line'>360</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="WHIT"> 
<span class='line'>361</span> 				</span><span class="STRN">'BT\n/'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>362</span> </span><span class="WHIT">				</span><span class="NAME">getFont</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">fontSize</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' Tf\n'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>363</span> </span><span class="WHIT">				</span><span class="NAME">fontSize</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' TL\n'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>364</span> </span><span class="WHIT">				</span><span class="NAME">textColor</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> 
<span class='line'>365</span> 				</span><span class="NAME">sprintf</span><span class="PUNC">(</span><span class="STRN">'\n%.2f %.2f Td\n('</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> 
<span class='line'>366</span> 				</span><span class="NAME">str</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>367</span> </span><span class="WHIT">				</span><span class="STRN">') Tj\nET'</span><span class="WHIT">
<span class='line'>368</span> </span><span class="WHIT">			</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>369</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_jsPDF</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>370</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>371</span> </span><span class="WHIT">		</span><span class="NAME">line</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>372</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">str</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sprintf</span><span class="PUNC">(</span><span class="STRN">'%.2f %.2f m %.2f %.2f l S'</span><span class="PUNC">,</span><span class="NAME">x1</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">y1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x2</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">y2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>373</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>374</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_jsPDF</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>375</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>376</span> </span><span class="WHIT">		</span><span class="NAME">rect</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">w</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">h</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">style</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>377</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">op</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'S'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>378</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">style</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'F'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>379</span> </span><span class="WHIT">				</span><span class="NAME">op</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'f'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>380</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">style</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'FD'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">style</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'DF'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>381</span> </span><span class="WHIT">				</span><span class="NAME">op</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'B'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>382</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>383</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">sprintf</span><span class="PUNC">(</span><span class="STRN">'%.2f %.2f %.2f %.2f re %s'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">w</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">op</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>384</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_jsPDF</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>385</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>386</span> </span><span class="WHIT">		</span><span class="NAME">ellipse</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">rx</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ry</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">style</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>387</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">op</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'S'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>388</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">style</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'F'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>389</span> </span><span class="WHIT">				</span><span class="NAME">op</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'f'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>390</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">style</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'FD'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">style</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'DF'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>391</span> </span><span class="WHIT">				</span><span class="NAME">op</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'B'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>392</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>393</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">lx</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="PUNC">/</span><span class="NUMB">3</span><span class="PUNC">*</span><span class="PUNC">(</span><span class="NAME">Math.SQRT2</span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">rx</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>394</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">ly</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="PUNC">/</span><span class="NUMB">3</span><span class="PUNC">*</span><span class="PUNC">(</span><span class="NAME">Math.SQRT2</span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">ry</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>395</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">sprintf</span><span class="PUNC">(</span><span class="STRN">'%.2f %.2f m %.2f %.2f %.2f %.2f %.2f %.2f c'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>396</span> </span><span class="WHIT">			        </span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">+</span><span class="NAME">rx</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="PUNC">-</span><span class="NAME">y</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>397</span> 			        </span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">+</span><span class="NAME">rx</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="PUNC">-</span><span class="PUNC">(</span><span class="NAME">y</span><span class="PUNC">-</span><span class="NAME">ly</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>398</span> 			        </span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">+</span><span class="NAME">lx</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="PUNC">-</span><span class="PUNC">(</span><span class="NAME">y</span><span class="PUNC">-</span><span class="NAME">ry</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>399</span> 			        </span><span class="NAME">x</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="PUNC">-</span><span class="PUNC">(</span><span class="NAME">y</span><span class="PUNC">-</span><span class="NAME">ry</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>400</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">sprintf</span><span class="PUNC">(</span><span class="STRN">'%.2f %.2f %.2f %.2f %.2f %.2f c'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>401</span> </span><span class="WHIT">			        </span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">-</span><span class="NAME">lx</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="PUNC">-</span><span class="PUNC">(</span><span class="NAME">y</span><span class="PUNC">-</span><span class="NAME">ry</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>402</span> 			        </span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">-</span><span class="NAME">rx</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="PUNC">-</span><span class="PUNC">(</span><span class="NAME">y</span><span class="PUNC">-</span><span class="NAME">ly</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>403</span> 			        </span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">-</span><span class="NAME">rx</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="PUNC">-</span><span class="NAME">y</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">			
<span class='line'>404</span> 			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">sprintf</span><span class="PUNC">(</span><span class="STRN">'%.2f %.2f %.2f %.2f %.2f %.2f c'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>405</span> </span><span class="WHIT">			        </span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">-</span><span class="NAME">rx</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="PUNC">-</span><span class="PUNC">(</span><span class="NAME">y</span><span class="PUNC">+</span><span class="NAME">ly</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>406</span> 			        </span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">-</span><span class="NAME">lx</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="PUNC">-</span><span class="PUNC">(</span><span class="NAME">y</span><span class="PUNC">+</span><span class="NAME">ry</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>407</span> 			        </span><span class="NAME">x</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="PUNC">-</span><span class="PUNC">(</span><span class="NAME">y</span><span class="PUNC">+</span><span class="NAME">ry</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>408</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">sprintf</span><span class="PUNC">(</span><span class="STRN">'%.2f %.2f %.2f %.2f %.2f %.2f c %s'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>409</span> </span><span class="WHIT">			        </span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">+</span><span class="NAME">lx</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="PUNC">-</span><span class="PUNC">(</span><span class="NAME">y</span><span class="PUNC">+</span><span class="NAME">ry</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>410</span> 			        </span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">+</span><span class="NAME">rx</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="PUNC">-</span><span class="PUNC">(</span><span class="NAME">y</span><span class="PUNC">+</span><span class="NAME">ly</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>411</span> 			        </span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">+</span><span class="NAME">rx</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="PUNC">-</span><span class="NAME">y</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>412</span> 			        </span><span class="NAME">op</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>413</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_jsPDF</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>414</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>415</span> </span><span class="WHIT">		</span><span class="NAME">circle</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">style</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>416</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.ellipse</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">style</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>417</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>418</span> </span><span class="WHIT">		</span><span class="NAME">setProperties</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">properties</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>419</span> </span><span class="WHIT">			</span><span class="NAME">documentProperties</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">properties</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>420</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_jsPDF</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>421</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>422</span> </span><span class="WHIT">		</span><span class="NAME">addImage</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">imageData</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">w</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">h</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>423</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_jsPDF</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>424</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>425</span> </span><span class="WHIT">		</span><span class="NAME">output</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>426</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>427</span> </span><span class="WHIT">				</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">buildDocument</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>428</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>429</span> </span><span class="WHIT">			</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'datauri'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>430</span> </span><span class="WHIT">				</span><span class="NAME">document.location.href</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'data:application/pdf;base64,'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">Base64.encode</span><span class="PUNC">(</span><span class="NAME">buildDocument</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>431</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>432</span> </span><span class="WHIT">			</span><span class="COMM">// @TODO: Add different output options</span><span class="WHIT">
<span class='line'>433</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>434</span> </span><span class="WHIT">		</span><span class="NAME">setFontSize</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">size</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>435</span> </span><span class="WHIT">			</span><span class="NAME">fontSize</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">size</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>436</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_jsPDF</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>437</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>438</span> </span><span class="WHIT">		</span><span class="NAME">setFont</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>439</span> </span><span class="WHIT">			</span><span class="KEYW">switch</span><span class="PUNC">(</span><span class="NAME">name.toLowerCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>440</span> </span><span class="WHIT">				</span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NAME">HELVETICA</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>441</span> </span><span class="WHIT">				</span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NAME">TIMES</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>442</span> </span><span class="WHIT">				</span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NAME">COURIER</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>443</span> </span><span class="WHIT">					</span><span class="NAME">fontName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">name.toLowerCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>444</span> </span><span class="WHIT">					</span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>445</span> </span><span class="WHIT">				</span><span class="KEYW">default</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>446</span> </span><span class="WHIT">					</span><span class="COMM">// do nothing</span><span class="WHIT">
<span class='line'>447</span> </span><span class="WHIT">					</span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>448</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>449</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_jsPDF</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>450</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>451</span> </span><span class="WHIT">		</span><span class="NAME">setFontType</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>452</span> </span><span class="WHIT">			</span><span class="KEYW">switch</span><span class="PUNC">(</span><span class="NAME">type.toLowerCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>453</span> </span><span class="WHIT">				</span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NAME">NORMAL</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>454</span> </span><span class="WHIT">				</span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NAME">BOLD</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>455</span> </span><span class="WHIT">				</span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NAME">ITALIC</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>456</span> </span><span class="WHIT">				</span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NAME">BOLD_ITALIC</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>457</span> </span><span class="WHIT">					</span><span class="NAME">fontType</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">type.toLowerCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>458</span> </span><span class="WHIT">					</span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>459</span> </span><span class="WHIT">				</span><span class="KEYW">default</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>460</span> </span><span class="WHIT">					</span><span class="COMM">// do nothing</span><span class="WHIT">
<span class='line'>461</span> </span><span class="WHIT">					</span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>462</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>463</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_jsPDF</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>464</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>465</span> </span><span class="WHIT">		</span><span class="NAME">setLineWidth</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">width</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>466</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">sprintf</span><span class="PUNC">(</span><span class="STRN">'%.2f w'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">width</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>467</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_jsPDF</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>468</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>469</span> </span><span class="WHIT">		</span><span class="NAME">setDrawColor</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">r</span><span class="PUNC">,</span><span class="NAME">g</span><span class="PUNC">,</span><span class="NAME">b</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>470</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">color</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>471</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">r</span><span class="PUNC">===</span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">g</span><span class="PUNC">===</span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">b</span><span class="PUNC">===</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">g</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>472</span> </span><span class="WHIT">				</span><span class="NAME">color</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sprintf</span><span class="PUNC">(</span><span class="STRN">'%.3f G'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">/</span><span class="NUMB">255</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>473</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>474</span> </span><span class="WHIT">				</span><span class="NAME">color</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sprintf</span><span class="PUNC">(</span><span class="STRN">'%.3f %.3f %.3f RG'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">/</span><span class="NUMB">255</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">g</span><span class="PUNC">/</span><span class="NUMB">255</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">b</span><span class="PUNC">/</span><span class="NUMB">255</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>475</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>476</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">color</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>477</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_jsPDF</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>478</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>479</span> </span><span class="WHIT">		</span><span class="NAME">setFillColor</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">r</span><span class="PUNC">,</span><span class="NAME">g</span><span class="PUNC">,</span><span class="NAME">b</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>480</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">color</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>481</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">r</span><span class="PUNC">===</span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">g</span><span class="PUNC">===</span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">b</span><span class="PUNC">===</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">g</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>482</span> </span><span class="WHIT">				</span><span class="NAME">color</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sprintf</span><span class="PUNC">(</span><span class="STRN">'%.3f g'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">/</span><span class="NUMB">255</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>483</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>484</span> </span><span class="WHIT">				</span><span class="NAME">color</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sprintf</span><span class="PUNC">(</span><span class="STRN">'%.3f %.3f %.3f rg'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">/</span><span class="NUMB">255</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">g</span><span class="PUNC">/</span><span class="NUMB">255</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">b</span><span class="PUNC">/</span><span class="NUMB">255</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>485</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>486</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">color</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>487</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_jsPDF</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>488</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>489</span> </span><span class="WHIT">		</span><span class="NAME">setTextColor</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">r</span><span class="PUNC">,</span><span class="NAME">g</span><span class="PUNC">,</span><span class="NAME">b</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>490</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">r</span><span class="PUNC">===</span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">g</span><span class="PUNC">===</span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">b</span><span class="PUNC">===</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">g</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>491</span> </span><span class="WHIT">				</span><span class="NAME">textColor</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sprintf</span><span class="PUNC">(</span><span class="STRN">'%.3f g'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">/</span><span class="NUMB">255</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>492</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>493</span> </span><span class="WHIT">				</span><span class="NAME">textColor</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sprintf</span><span class="PUNC">(</span><span class="STRN">'%.3f %.3f %.3f rg'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">/</span><span class="NUMB">255</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">g</span><span class="PUNC">/</span><span class="NUMB">255</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">b</span><span class="PUNC">/</span><span class="NUMB">255</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>494</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>495</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_jsPDF</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>496</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>497</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>498</span> 
<span class='line'>499</span> </span><span class="WHIT">	</span><span class="COMM">/////////////////////////////////////////</span><span class="WHIT">
<span class='line'>500</span> </span><span class="WHIT">	</span><span class="COMM">// Initilisation if jsPDF Document object</span><span class="WHIT">
<span class='line'>501</span> </span><span class="WHIT">	</span><span class="COMM">/////////////////////////////////////////</span><span class="WHIT">
<span class='line'>502</span> </span><span class="WHIT">	
<span class='line'>503</span> 	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">unit</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'pt'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>504</span> </span><span class="WHIT">		</span><span class="NAME">k</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>505</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">unit</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'mm'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>506</span> </span><span class="WHIT">		</span><span class="NAME">k</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">72</span><span class="PUNC">/</span><span class="NUMB">25.4</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>507</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">unit</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'cm'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>508</span> </span><span class="WHIT">		</span><span class="NAME">k</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">72</span><span class="PUNC">/</span><span class="NUMB">2.54</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>509</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">unit</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'in'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>510</span> </span><span class="WHIT">		</span><span class="NAME">k</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">72</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>511</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>512</span> </span><span class="WHIT">		</span><span class="KEYW">throw</span><span class="PUNC">(</span><span class="STRN">'Invalid unit: '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">unit</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>513</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>514</span> </span><span class="WHIT">	
<span class='line'>515</span> 	</span><span class="COMM">// Dimensions are stored as user units and converted to points on output</span><span class="WHIT">
<span class='line'>516</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">format_as_string</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">pageFormats</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>517</span> </span><span class="WHIT">		</span><span class="NAME">pageHeight</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pageFormats</span><span class="PUNC">[</span><span class="NAME">format_as_string</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>518</span> </span><span class="WHIT">		</span><span class="NAME">pageWidth</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pageFormats</span><span class="PUNC">[</span><span class="NAME">format_as_string</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>519</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>520</span> </span><span class="WHIT">		</span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>521</span> </span><span class="WHIT">			</span><span class="NAME">pageHeight</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>522</span> </span><span class="WHIT">			</span><span class="NAME">pageWidth</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>523</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT"> 
<span class='line'>524</span> 		</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">err</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>525</span> </span><span class="WHIT">			</span><span class="KEYW">throw</span><span class="PUNC">(</span><span class="STRN">'Invalid format: '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>526</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>527</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>528</span> </span><span class="WHIT">	
<span class='line'>529</span> 	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">orientation</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'p'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">orientation</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'portrait'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>530</span> </span><span class="WHIT">		</span><span class="NAME">orientation</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'p'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>531</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">orientation</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'l'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">orientation</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'landscape'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>532</span> </span><span class="WHIT">		</span><span class="NAME">orientation</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'l'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>533</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">tmp</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pageWidth</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>534</span> </span><span class="WHIT">		</span><span class="NAME">pageWidth</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pageHeight</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>535</span> </span><span class="WHIT">		</span><span class="NAME">pageHeight</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tmp</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>536</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>537</span> </span><span class="WHIT">		</span><span class="KEYW">throw</span><span class="PUNC">(</span><span class="STRN">'Invalid orientation: '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">orientation</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>538</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>539</span> 
<span class='line'>540</span> </span><span class="WHIT">	</span><span class="COMM">// Add the first page automatically</span><span class="WHIT">
<span class='line'>541</span> </span><span class="WHIT">	</span><span class="NAME">addFonts</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>542</span> </span><span class="WHIT">	</span><span class="NAME">_addPage</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">	
<span class='line'>543</span> 	
<span class='line'>544</span> 	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_jsPDF</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>545</span> </span><span class="PUNC">}</span><span class="PUNC">;</span></pre></body></html>